package com.jerry.response;

import com.jerry.interfaces.IResponse;
import lombok.Data;

@Data
public class CommonResponse<T> implements IResponse {
    private final int code;
    private final String message;
    private final T data;

    public static <T> CommonResponse<T> success(T data) {
        return new CommonResponse<>(200,"success",data);
    }

    public static <T> CommonResponse<T> error(T data){return new CommonResponse<>(500,"fail",data);}
    public static <T> CommonResponse<T> error() {
        return error(null);
    }
    public static <T> CommonResponse<T> success() {
        return success(null);
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return message;
    }
}
